<?php
class SiteAdmin extends CI_Controller{
	public function __construct(){
		parent::__construct();
		$this->display= new Display('templates/siteadmin');
		$this->load->helper(array('form', 'url','path','file'));
		$editing = $this->input->post('site_editing');
		
		if( $editing=="enabled" && empty($_SESSION['editing'] )|| $this->input->post('enable_site_editing') ){
			$_SESSION['editing']=1;
			$this->display->editingon = "checked";
		}
		else if( !empty($editing) && $editing=="enabled" && !empty($_SESSION['editing']) ){
			unset( $_SESSION['editing'] );
		}
		else if( empty($editing)&& !empty($_SESSION['editing']) ){
			$this->display->editingon = "checked";
		}
		$this->display->addJSInit("
		$(function() {
		$('#enable_site_editing').button();
		$('#enable_site_editing').click( function(){
			$('#enable_site_editing').parent().submit();
		});
		});
		");
	}
}
?>